package com.qdsgjsfk.vision.ui.fragment;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.qdsgjsfk.vision.R;
import com.qdsgjsfk.vision.adapter.MultipleAdapter;
import com.qdsgjsfk.vision.base.BaseApplication;
import com.qdsgjsfk.vision.base.BaseFragment;
import com.qdsgjsfk.vision.eventbus.BlueTooth;
import com.qdsgjsfk.vision.eventbus.Clear;
import com.qdsgjsfk.vision.model.BlueToothDataJson;
import com.qdsgjsfk.vision.service.SocketService;
import com.qdsgjsfk.vision.ui.dialog.RemarkDialog;
import com.qdsgjsfk.vision.util.Constant;
import com.qdsgjsfk.vision.util.DiopterDataUtil;
import com.qdsgjsfk.vision.util.NetUtil;
import com.qdsgjsfk.vision.util.UtilString;
import com.rest.business.RestProxy;
import com.rest.response.QualifiedResponse;
import com.rest.response.StudentOtherResponse;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import jz.joyoung.robot.util.LogUtil;
import util.UtilList;

/**
 * Created by HP on 2018/10/8.
 */

public class OtherChooseFragment extends BaseFragment {


    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    @BindView(R.id.btn_confirm)
    TextView btnConfirm;
//    @BindView(R.id.ll_bottom)
//    LinearLayout llBottom;

    @BindView(R.id.tv_examiner)
    TextView tvExaminer;
    @BindView(R.id.tv_examiner_time)
    TextView tvExaminerTime;
    @BindView(R.id.refreshLayout)
    SmartRefreshLayout refreshLayout;

    Unbinder unbinder;
    List<StudentOtherResponse.OtherExamineOptions> list = new ArrayList<>();


    private OptionsPickerView pvOptions, pvCustomOptions, pvNumberOptions;
    private ArrayList<String> dataCustom = new ArrayList<>();
    //    Map mapsId = new LinkedHashMap();
//    Map mapsOptionId = new LinkedHashMap();
//    Map mapsOptionName = new LinkedHashMap();
//    Map mapsIsMust = new LinkedHashMap();
//    Map mapsIsDistinguishLrEye = new LinkedHashMap();
//    Map<String, Integer> mapsSelection = new LinkedHashMap();
//    List<String> listIsDistinguishLrEye = new ArrayList();
//    Map mapCustomName = new LinkedHashMap();
//    Map mapsLeftData = new LinkedHashMap();
//    Map mapsRightData = new LinkedHashMap();
    private FragmentOtherAdapter fragmentOtherAdapter;
    private List<String> listCustomId = new ArrayList<>();
    String studentId, submitType, taskId, id;
    private boolean isCanSubmit;
    private RemarkDialog mRemarkDialog;

    /**
     * EventBus传值
     *
     * @time 2020/5/28 16:00
     */
    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onMessageEvent(BlueTooth event) {

        if (event.type == 110) {
            Log.e( "Data_OD==", event.output );
            try {
                JSONObject object = new JSONObject( event.output );
                JSONObject data_od = object.getJSONObject( "Data_OD" );
                JSONObject data_os = object.getJSONObject( "Data_OS" );
                if (!UtilList.isEmpty( list )) {
                    for (StudentOtherResponse.OtherExamineOptions options : list) {
                        int isDistinguishLrEye = options.isDistinguishLrEye;
                        String optionName = options.optionName;
                        if ("眼轴长度".equals( optionName )) {
                            String alOd = data_od.optString( "AL" );
                            String alOs = data_os.optString( "AL" );
                            if (!UtilString.isEmpty( alOd )) {
                                options.odData = alOd;
                            }
                            if (!UtilString.isEmpty( alOs )) {
                                options.osData = alOs;
                            }
                        } else if ("中央角膜厚度".equals( optionName )) {
                            String cctOd = data_od.optString( "CCT" );
                            String cctOs = data_os.optString( "CCT" );
                            if (!UtilString.isEmpty( cctOd )) {
                                options.odData = cctOd;
                            }
                            if (!UtilString.isEmpty( cctOs )) {
                                options.osData = cctOs;
                            }
                        } else if ("前房深度".equals( optionName )) {
                            String adOd = data_od.optString( "AD" );
                            String adOs = data_os.optString( "AD" );
                            if (!UtilString.isEmpty( adOd )) {
                                options.odData = adOd;
                            }
                            if (!UtilString.isEmpty( adOs )) {
                                options.osData = adOs;
                            }
                        } else if ("晶体厚度".equals( optionName )) {
                            String ltOd = data_od.optString( "LT" );
                            String ltOs = data_os.optString( "LT" );
                            if (!UtilString.isEmpty( ltOd )) {
                                options.odData = ltOd;
                            }
                            if (!UtilString.isEmpty( ltOs )) {
                                options.osData = ltOs;
                            }
                        } else if ("玻璃体厚度".equals( optionName )) {
                            String vtOd = data_od.optString( "VT" );
                            String vtOs = data_os.optString( "VT" );
                            if (!UtilString.isEmpty( vtOd )) {
                                options.odData = vtOd;
                            }
                            if (!UtilString.isEmpty( vtOs )) {
                                options.osData = vtOs;
                            }
                        } else if ("散光度数".equals( optionName )) {
                            String astOd = data_od.optString( "AST" );
                            if (!UtilString.isEmpty( astOd )) {
                                options.odData = astOd;
                            }
                            String astOs = data_os.optString( "AST" );
                            if (!UtilString.isEmpty( astOs )) {
                                options.osData = astOs;
                            }
                        } else if ("白对白".equals( optionName )) {
                            String wtwOd = data_od.optString( "WTW" );
                            if (!UtilString.isEmpty( wtwOd )) {
                                options.odData = wtwOd;
                            }
                            String wtwOs = data_os.optString( "WTW" );
                            if (!UtilString.isEmpty( wtwOs )) {
                                options.osData = wtwOs;
                            }
                        } else if ("瞳孔直径".equals( optionName )) {
                            String pdOd = data_od.optString( "PD" );
                            if (!UtilString.isEmpty( pdOd )) {
                                options.odData = pdOd;
                            }
                            String pdOs = data_os.optString( "PD" );
                            if (!UtilString.isEmpty( pdOs )) {
                                options.osData = pdOs;
                            }
                        } else if ("K1".equals( optionName )) {
                            String k1Od = data_od.optString( "K1" );
                            if (!UtilString.isEmpty( k1Od )) {
                                options.odData = k1Od;
                            }
                            String k1Os = data_os.optString( "K1" );
                            if (!UtilString.isEmpty( k1Os )) {
                                options.osData = k1Os;
                            }
                        } else if ("A1".equals( optionName )) {
                            String a1Od = data_od.optString( "A1" );
                            if (!UtilString.isEmpty( a1Od )) {
                                options.odData = a1Od;
                            }
                            String a1Os = data_os.optString( "A1" );
                            if (!UtilString.isEmpty( a1Os )) {
                                options.osData = a1Os;
                            }
                        } else if ("K2".equals( optionName )) {
                            String k2Od = data_od.optString( "K2" );
                            if (!UtilString.isEmpty( k2Od )) {
                                options.odData = k2Od;
                            }
                            String k2Os = data_os.optString( "K2" );
                            if (!UtilString.isEmpty( k2Os )) {
                                options.osData = k2Os;
                            }
                        } else if ("A2".equals( optionName )) {
                            String a2Od = data_od.optString( "A2" );
                            if (!UtilString.isEmpty( a2Od )) {
                                options.odData = a2Od;
                            }
                            String a2Os = data_os.optString( "A2" );
                            if (!UtilString.isEmpty( a2Os )) {
                                options.osData = a2Os;
                            }
                        }


                    }
                    fragmentOtherAdapter.notifyDataSetChanged();
                }


            } catch (JSONException e) {
                e.printStackTrace();
            }

            EventBus.getDefault().postSticky( new Clear( 1 ) );
        }
    }

    @Override
    protected void initData() {
        assert getArguments() != null;
        studentId = getArguments().getString( "studentId" );
        taskId = getArguments().getString( "taskId" );
        if (!EventBus.getDefault().isRegistered( this )) {
            EventBus.getDefault().register( this );
        }
    }


    public static OtherChooseFragment newInstance(String studentId, String taskId) {
        Bundle args = new Bundle();
        args.putString( "studentId", studentId );
        args.putString( "taskId", taskId );
        OtherChooseFragment fragment = new OtherChooseFragment();
        fragment.setArguments( args );

        return fragment;
    }


    @Override
    protected int getLayoutResource() {
        return R.layout.fragment_other;
    }

    @Override
    protected void initView() {
        LinearLayoutManager managerOffline = new LinearLayoutManager( getActivity() );
        managerOffline.setOrientation( LinearLayoutManager.VERTICAL );
        recyclerView.setLayoutManager( managerOffline );
        fragmentOtherAdapter = new FragmentOtherAdapter();
        recyclerView.setAdapter( fragmentOtherAdapter );
        recyclerView.addItemDecoration( new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets( outRect, view, parent, state );
                outRect.bottom = 40;
            }
        } );

        initNumberOptionsPicker();
        refreshLayout.setPrimaryColors( 0xffffffff, 0xff55B8A9 );
        refreshLayout.setEnableLoadMore( false );
        refreshLayout.setOnRefreshListener( refreshLayout -> {
            mContext.stopService( new Intent( mContext, SocketService.class ) );
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                mContext.startForegroundService( new Intent( mContext, SocketService.class ) );
            } else {
                mContext.startService( new Intent( mContext, SocketService.class ) );
            }
            new Handler().postDelayed( () -> refreshLayout.finishRefresh( true ), 1000 );

        } );
    }

    /**
     * 初始化数值选择器
     *
     * @time 2020/5/28 11:39
     */
    private void initNumberOptionsPicker() {

    }


    @Override
    public void onStart() {
        super.onStart();
        getInfo();
    }

    /**
     * 获取其他功能的筛查项列表
     *
     * @time 2020/5/28 11:37
     */
    private void getInfo() {
        RestProxy.getInstance().getOtherExamineOptions( studentId + "", taskId, new Observer<StudentOtherResponse>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @SuppressLint("SetTextI18n")
            @Override
            public void onNext(StudentOtherResponse studentResponse) {
                try {
                    //这里写可能出现异常的语句
                    if (studentResponse.data.otherExamineOptions != null) {
                        list.clear();
                        list.addAll( studentResponse.data.otherExamineOptions );
                        Log.e( "OtherChooseFragment----", list.size() + "" );
                        if (studentResponse.data.OtherExamineOptionCommon.checker != null) {
                            tvExaminer.setText( "检查人:" + studentResponse.data.OtherExamineOptionCommon.checker );
                        }
                        if (studentResponse.data.OtherExamineOptionCommon.checkedTime != null) {
                            tvExaminerTime.setText( "检查时间:" + studentResponse.data.OtherExamineOptionCommon.checkedTime );
                        }
                    }
                    //备注不为空
                    //                    tv_remark.setTextColor(ContextCompat.getColor(activity, R.color.lightBlack));
                    //                    tv_remark.setText(studentResponse.data.OtherExamineOptionCommon.remark);
                    isCanSubmit = !UtilString.isEmpty( studentResponse.data.OtherExamineOptionCommon.remark );
                    fragmentOtherAdapter.notifyDataSetChanged();
                    for (int i = 0; i < list.size(); i++) {
                        String id = list.get( i ).id;
//                     String optionId = list.get(i).optionId;
                        if (UtilString.isEmpty( id )) {
                            submitType = "save";
//                        mapsId.put(optionId, "");
                        } else {
                            submitType = "update";
//                        mapsId.put(optionId, id);
                        }
//                    mapsOptionId.put(optionId, list.get(i).optionId);
//                    mapsOptionName.put(optionId, list.get(i).optionName);
//                    mapsIsMust.put(optionId, list.get(i).selection);
//                    mapsIsDistinguishLrEye.put(optionId, list.get(i).isDistinguishLrEye);
//                    if (list.get(i).selection == 1) {
//                        //必查
//                        mapsSelection.put(optionId, list.get(i).selection);
//                    }
//                    if (list.get(i).isDistinguishLrEye == 0) {
//                        //不区分左右眼
//                        if (!UtilString.isEmpty(list.get(i).odData)) {
//                            mapsRightData.put(optionId, list.get(i).odData);
//                        } else {
//                            mapsRightData.put(optionId, "");
//                        }
//
//                        mapsLeftData.put(optionId, "");
//                    } else {
//                        if (!UtilString.isEmpty(list.get(i).odData)) {
//                            mapsRightData.put(optionId, list.get(i).odData);
//                        } else {
//                            mapsRightData.put(optionId, "");
//                        }
//                        if (!UtilString.isEmpty(list.get(i).osData)) {
//                            mapsLeftData.put(optionId, list.get(i).osData);
//                        } else {
//                            mapsLeftData.put(optionId, "");
//                        }
//
//                    }
//
                    }

                    changeBottomSave( true );
                } catch (Exception e) {
                    // 捕获异常，如果要捕获Json数据异常，写catch(JSONException e)
                    e.printStackTrace();
                }

            }

            @Override
            public void onError(Throwable e) {
                e.printStackTrace();
                NetUtil.onError( e, mContext );
            }

            @Override
            public void onComplete() {

            }
        } );
    }


    @OnClick(R.id.btn_confirm)
    void btn_confirm() {
//        if (mapsSelection.size() == 0) {
//            //没有必填项，全是选填
//            int emptyNum = 0;
//            //没有必填项
//            Iterator itRight = mapsRightData.entrySet().iterator();
//            while (itRight.hasNext()) {
//                Map.Entry entity = (Map.Entry) itRight.next();
//                if (UtilString.isEmpty((String) entity.getValue())) {
//                    //右眼数据有一项为空
//                    emptyNum += 1;
//                }
//            }
//        }
//
//        if (isCanSubmit) {
//            requestInterface();
//        } else {
//            changeBottomSave(false);
//        }
        if (checkMust()) {
            requestInterface();
        } else {
            Toast.makeText( mContext, "请填写必填项", Toast.LENGTH_SHORT ).show();
        }


    }


    private boolean checkMust() {
        for (StudentOtherResponse.OtherExamineOptions other : list) {
            if (other.selection == 1) {
                if (TextUtils.isEmpty( other.odData ))
                    return false;
                if (other.isDistinguishLrEye == 1) {
                    if (TextUtils.isEmpty( other.osData ))
                        return false;
                }
            }
        }
        return true;
    }

//    @OnClick(R.id.btn_remark)
////    void btn_remark() {
////        showRemarkDialog();
////    }

    private void requestInterface() {

//        List<Map<String, Object>> listOne = new ArrayList<>();
//        Iterator itOptionId = mapsOptionId.entrySet().iterator();
//        while (itOptionId.hasNext()) {
//            Map<String, Object> map2 = new HashMap<>();//body  map
//            Log.e("id个数--", mapsOptionId.size() + "");
//            Map.Entry entityOptionId = (Map.Entry) itOptionId.next();
//            map2.put("optionId", entityOptionId.getValue());
//            Iterator itId = mapsId.entrySet().iterator();
//            while (itId.hasNext()) {
//                Map.Entry entityId = (Map.Entry) itId.next();
//                if (entityOptionId.getValue().equals(entityId.getKey())) {
//                    map2.put("id", entityId.getValue());
//                    Iterator itRight = mapsRightData.entrySet().iterator();
//                    while (itRight.hasNext()) {
//                        Map.Entry entity = (Map.Entry) itRight.next();
//                        if (entityOptionId.getValue().equals(entity.getKey())) {
//                            map2.put("odData", entity.getValue());
//                            Iterator itLeft = mapsLeftData.entrySet().iterator();
//                            while (itLeft.hasNext()) {
//                                Map.Entry entityLeft = (Map.Entry) itLeft.next();
//                                if (entityOptionId.getValue().equals(entityLeft.getKey())) {
//                                    map2.put("osData", entityLeft.getValue());
//                                    Iterator itName = mapsOptionName.entrySet().iterator();
//                                    while (itName.hasNext()) {
//                                        Map.Entry entityName = (Map.Entry) itName.next();
//                                        if (entityOptionId.getValue().equals(entityName.getKey())) {
//                                            map2.put("optionName", entityName.getValue());
//                                        }
//                                    }
//                                }
//                            }
//
//                        }
//
//                    }
//                }
//
//            }
//
//            listOne.add(map2);
//
//        }

        Map<String, Object> map = new HashMap<>();//body  map
        map.put( "studentId", studentId );
        map.put( "taskId", taskId );
        map.put( "id", id );
        map.put( "dataList", list );
        if ("save".equals( submitType )) {
            RestProxy.getInstance().addStudentInfoQt( map, new Observer<QualifiedResponse>() {
                @Override
                public void onSubscribe(Disposable d) {
                    btnConfirm.setClickable( false );
                    showProgressDialog();
                }

                @Override
                public void onNext(QualifiedResponse qualifiedResponse) {
                    if (OtherChooseFragment.this.isAdded()) {
                        dismissProgressDialog();
                    }
//                    mapsId.clear();
//                    mapsLeftData.clear();
//                    mapsRightData.clear();
                    Toast.makeText( mContext, "保存成功", Toast.LENGTH_SHORT ).show();
                    mContext.finish();
//                    if (qualifiedResponse.data) {
//                        showQualifiedDialog( "屈光与视力不匹配，建议重新检查" );
//                    } else {
//                        Toast.makeText( activity, "保存成功", Toast.LENGTH_SHORT ).show();
//                        if (isNext) {
//                            if ("1".equals( taskType )) {
//                                ((StudentDetailActivity) getActivity()).setmViewPager( 0 );
//                            } else if ("3".equals( taskType )) {
//                                ((StudentDetailOtherActivity) getActivity()).setmViewPager( 0 );
//                            }
//                            EventBus.getDefault().postSticky( new StartVision( 0 ) );
//                            getInfo();
//                        } else {
//                            activity.finish();
//                        }
//                    }
                }

                @Override
                public void onError(Throwable e) {
                    dismissProgressDialog();
                    NetUtil.onError( e, mContext );
                    btnConfirm.setClickable( true );
                }

                @Override
                public void onComplete() {
                }
            } );
        } else if ("update".equals( submitType )) {
            RestProxy.getInstance().editStudentInfoQt( map, new Observer<QualifiedResponse>() {
                @Override
                public void onSubscribe(Disposable d) {
                    btnConfirm.setClickable( false );
                    showProgressDialog();
                }

                @Override
                public void onNext(QualifiedResponse qualifiedResponse) {
                    if (OtherChooseFragment.this.isAdded()) {
                        dismissProgressDialog();
                    }
//                    mapsId.clear();
//                    mapsLeftData.clear();
//                    mapsRightData.clear();
                    Toast.makeText( mContext, "保存成功", Toast.LENGTH_SHORT ).show();
                    mContext.finish();
//                    if (qualifiedResponse.data) {
//                        showQualifiedDialog( "屈光与视力不匹配，建议重新检查" );
//                    } else {
//                        Toast.makeText( activity, "保存成功", Toast.LENGTH_SHORT ).show();
//                        if (isNext) {
//                            if ("1".equals( taskType )) {
//                                ((StudentDetailActivity) getActivity()).setmViewPager( 0 );
//                            } else if ("3".equals( taskType )) {
//                                ((StudentDetailOtherActivity) getActivity()).setmViewPager( 0 );
//                            }
//                            EventBus.getDefault().postSticky( new StartVision( 0 ) );
//                            getInfo();
//                        } else {
//                            activity.finish();
//                        }
//                    }
                }

                @Override
                public void onError(Throwable e) {
                    dismissProgressDialog();
                    NetUtil.onError( e, mContext );
                    btnConfirm.setClickable( true );
                }

                @Override
                public void onComplete() {

                }
            } );
        }
    }


    class FragmentOtherAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

        @Override
        public int getItemViewType(int position) {
            return list.get( position ).itemType;
        }

        @NonNull
        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            if (viewType == 3)
                return new MultipleHolder( getLayoutInflater().inflate( R.layout.item_fragment_other_multiple, parent, false ) );
            else
                return new TaskHolder( getLayoutInflater().inflate( R.layout.item_fragment_other, parent, false ) );
        }

        @SuppressLint("SetTextI18n")
        @Override
        public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") final int position) {
            if (holder instanceof MultipleHolder) {
                if (list.get( position ).selection == 1) {//必查
                    ((MultipleHolder) holder).tvOptionName.setText( list.get( position ).optionName );
                } else if (list.get( position ).selection == 2) {
                    ((MultipleHolder) holder).tvOptionName.setText( list.get( position ).optionName + "(选填)" );
                }
                GridLayoutManager manager_first = new GridLayoutManager( mContext, 12 );
                manager_first.setSpanSizeLookup( new GridLayoutManager.SpanSizeLookup() {
                    @Override
                    public int getSpanSize(int innerPosition) {
                        return list.get( position ).multipleChoiceQuery.get( innerPosition ).paramName.length();
                    }
                } );
                ((MultipleHolder) holder).recyclerView_first.setLayoutManager( manager_first );
                if (TextUtils.isEmpty( list.get( position ).odData )) {
                    for (StudentOtherResponse.MultipleChoiceQuery multipleChoiceQuery : list.get( position ).multipleChoiceQuery) {
                        if (multipleChoiceQuery.odChoosed == 1)
                            list.get( position ).odData = multipleChoiceQuery.paramName;
                    }
                }
                MultipleAdapter multipleAdapter_first = new MultipleAdapter( mContext, list.get( position ).multipleChoiceQuery, list.get( position ).isDistinguishLrEye, new MultipleAdapter.OnItemSelectListener() {
                    @Override
                    public void onItemSelect(String para, int isVisible) {
                        list.get( position ).odData = para;
                        ((MultipleHolder) holder).edt_remark_first.setVisibility( isVisible );
                        if (isVisible == View.GONE) {
                            ((MultipleHolder) holder).edt_remark_first.setText( "" );
                        }
                    }

                    @Override
                    public void onItemInit(int isVisible) {
                        ((MultipleHolder) holder).edt_remark_first.setVisibility( isVisible );
                    }
                } );
                ((MultipleHolder) holder).recyclerView_first.setAdapter( multipleAdapter_first );
                multipleAdapter_first.notifyDataSetChanged();
                ((MultipleHolder) holder).edt_remark_first.addTextChangedListener( new TextWatcher() {
                    @Override
                    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                    }

                    @Override
                    public void onTextChanged(CharSequence s, int start, int before, int count) {

                    }

                    @Override
                    public void afterTextChanged(Editable s) {
                        list.get( position ).odRemark = s.toString();
                    }
                } );
                ((MultipleHolder) holder).edt_remark_first.setText( list.get( position ).odRemark );

                if (list.get( position ).isDistinguishLrEye == 1) {
                    if (TextUtils.isEmpty( list.get( position ).odData )) {
                        list.get( position ).osData = list.get( position ).defaultParam;
                    }
                    GridLayoutManager manager_second = new GridLayoutManager( mContext, 12 );
                    manager_first.setSpanSizeLookup( new GridLayoutManager.SpanSizeLookup() {
                        @Override
                        public int getSpanSize(int innerPosition) {
                            return list.get( position ).multipleChoiceQuery.get( innerPosition ).paramName.length();
                        }
                    } );
                    ((MultipleHolder) holder).recyclerView_second.setLayoutManager( manager_second );
                    MultipleAdapter multipleAdapter_second = new MultipleAdapter( mContext, list.get( position ).multipleChoiceQuery, list.get( position ).isDistinguishLrEye, new MultipleAdapter.OnItemSelectListener() {
                        @Override
                        public void onItemSelect(String para, int isVisible) {
                            list.get( position ).osData = para;
                            ((MultipleHolder) holder).edt_remark_second.setVisibility( isVisible );
                            if (isVisible == View.GONE) {
                                ((MultipleHolder) holder).edt_remark_second.setText( "" );
                            }
                        }

                        @Override
                        public void onItemInit(int isVisible) {
                            ((MultipleHolder) holder).edt_remark_second.setVisibility( isVisible );
                        }
                    } );
                    ((MultipleHolder) holder).recyclerView_second.setAdapter( multipleAdapter_second );
                    multipleAdapter_second.notifyDataSetChanged();

                    ((MultipleHolder) holder).edt_remark_second.addTextChangedListener( new TextWatcher() {
                        @Override
                        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                        }

                        @Override
                        public void onTextChanged(CharSequence s, int start, int before, int count) {

                        }

                        @Override
                        public void afterTextChanged(Editable s) {
                            list.get( position ).osRemark = s.toString();
                        }
                    } );
                    ((MultipleHolder) holder).edt_remark_second.setText( list.get( position ).osRemark );
                }
            } else if (holder instanceof TaskHolder) {

                ((TaskHolder) holder).etOdData.setText( list.get( position ).odData );
                ((TaskHolder) holder).etOsData.setText( list.get( position ).osData );
                ((TaskHolder) holder).edt_remark_first.setText( list.get( position ).odRemark );
                ((TaskHolder) holder).edt_remark_second.setText( list.get( position ).osRemark );
                int itemType = list.get( position ).itemType;
                int isDistinguishLrEye = list.get( position ).isDistinguishLrEye;
                if (isDistinguishLrEye == 0) {
                    //是否区分左右眼 0-不区分
                    ((TaskHolder) holder).etOsData.setVisibility( View.INVISIBLE );
                    ((TaskHolder) holder).etUnitLeft.setVisibility( View.INVISIBLE );
                    ((TaskHolder) holder).tvRight.setVisibility( View.GONE );
                    ((TaskHolder) holder).tvLeft.setVisibility( View.GONE );
                    ((TaskHolder) holder).edt_remark_second.setVisibility( View.GONE );
                    ((TaskHolder) holder).ll_second.setVisibility( View.GONE );
                    if (TextUtils.isEmpty( list.get( position ).odData )) {
                        ((TaskHolder) holder).etOdData.setText( list.get( position ).defaultParam );
                        list.get( position ).odData = list.get( position ).defaultParam;
                    }
                    if (itemType == 1) {
                        //键盘输入
                        ((TaskHolder) holder).etUnitRight.setVisibility( View.VISIBLE );
                        ((TaskHolder) holder).etUnitRight.setText( list.get( position ).unit );
                    } else {
                        ((TaskHolder) holder).etOdData.setFocusableInTouchMode( false );
                        ((TaskHolder) holder).etUnitRight.setVisibility( View.INVISIBLE );
                    }
                } else if (isDistinguishLrEye == 1) {
                    ((TaskHolder) holder).etOsData.setVisibility( View.VISIBLE );
                    ((TaskHolder) holder).tvRight.setVisibility( View.VISIBLE );
                    ((TaskHolder) holder).tvLeft.setVisibility( View.VISIBLE );
                    ((TaskHolder) holder).edt_remark_second.setVisibility( View.VISIBLE );
                    ((TaskHolder) holder).ll_second.setVisibility( View.VISIBLE );
                    if (itemType == 1) {
                        //显示左右眼单位
                        ((TaskHolder) holder).etUnitLeft.setVisibility( View.VISIBLE );
                        ((TaskHolder) holder).etUnitRight.setVisibility( View.VISIBLE );
                        ((TaskHolder) holder).etUnitLeft.setText( list.get( position ).unit );
                        ((TaskHolder) holder).etUnitRight.setText( list.get( position ).unit );

                    } else {
                        ((TaskHolder) holder).etUnitLeft.setVisibility( View.INVISIBLE );
                        ((TaskHolder) holder).etUnitRight.setVisibility( View.INVISIBLE );
                    }
                    if (TextUtils.isEmpty( list.get( position ).odData )) {
                        ((TaskHolder) holder).etOdData.setText( list.get( position ).defaultParam );
                        list.get( position ).odData = list.get( position ).defaultParam;
                    }
                    if (TextUtils.isEmpty( list.get( position ).osData )) {
                        ((TaskHolder) holder).etOsData.setText( list.get( position ).defaultParam );
                        list.get( position ).osData = list.get( position ).defaultParam;
                    }
                }

                if (list.get( position ).selection == 1) {//必查
                    ((TaskHolder) holder).tvOptionName.setText( list.get( position ).optionName );
                } else if (list.get( position ).selection == 2) {
                    ((TaskHolder) holder).tvOptionName.setText( list.get( position ).optionName + "(选填)" );
                }

                if (!TextUtils.isEmpty( ((TaskHolder) holder).etOdData.getText().toString() )) {
                    if (((TaskHolder) holder).etOdData.getText().toString().equals( list.get( position ).needRemarkParam )) {
                        ((TaskHolder) holder).edt_remark_first.setVisibility( View.VISIBLE );
                    } else {
                        ((TaskHolder) holder).edt_remark_first.setVisibility( View.GONE );
                    }
                } else {
                    ((TaskHolder) holder).edt_remark_first.setVisibility( View.GONE );
                }

                if (isDistinguishLrEye == 1) {
                    if (!TextUtils.isEmpty( ((TaskHolder) holder).etOsData.getText().toString() )) {
                        if (((TaskHolder) holder).etOsData.getText().toString().equals( list.get( position ).needRemarkParam )) {
                            ((TaskHolder) holder).edt_remark_second.setVisibility( View.VISIBLE );
                        } else {
                            ((TaskHolder) holder).edt_remark_second.setVisibility( View.GONE );
                        }
                    } else {
                        ((TaskHolder) holder).edt_remark_second.setVisibility( View.GONE );
                    }
                }

                //右眼
                ((TaskHolder) holder).etOdData.setOnClickListener( v -> {
                    dataCustom.clear();
                    pvCustomOptions = null;
                    if (itemType == 0) {
                        hintKeyBoard( ((TaskHolder) holder).etOdData );
                        dataCustom.addAll( (list.get( position )).paramsArray );
                        initRightOptionPicker( ((TaskHolder) holder).etOdData, position );
                    } else if (itemType == 1) {
                        //数值选项
                        hintKeyBoard( ((TaskHolder) holder).etOdData );
                        requestFocusKeyBoard( ((TaskHolder) holder).etOdData );
                        ((TaskHolder) holder).etOdData.addTextChangedListener( new WatcherZW( ((TaskHolder) holder).etOdData, position, true ) );
//                        int num = Integer.parseInt( list.get( position ).num );
//                        String minValues = list.get( position ).minValues;
//                        Double intMin = Double.parseDouble( minValues );
//                        dataCustom.add( list.get( position ).minValues );
//                        for (int i = 0; i < num; i++) {
//                            Log.e( "doubleData---", intMin + "" );
//                            if (num != dataCustom.size()) {
//                                dataCustom.add( String.valueOf( UtilString.add( intMin, list.get( position ).intervalValues ) ) );
//                            }
//                            intMin = UtilString.add( intMin, list.get( position ).intervalValues );
//                            if (num == dataCustom.size()) {
//                                initRightOptionPicker( holder.etOdData, list.get( position ).optionId, list.get( position ).optionName, list.get( position ).isDistinguishLrEye + "" );
//                                break;
//                            }
//                        }
                    } else if (itemType == 2) {
                        //是否选项
                        hintKeyBoard( ((TaskHolder) holder).etOdData );
                        dataCustom.add( "是" );
                        dataCustom.add( "否" );
                        initRightOptionPicker( ((TaskHolder) holder).etOdData, position );
                    }
                } );
                ((TaskHolder) holder).etOdData.addTextChangedListener( new TextWatcher() {
                    @Override
                    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                    }

                    @Override
                    public void onTextChanged(CharSequence s, int start, int before, int count) {

                    }

                    @Override
                    public void afterTextChanged(Editable s) {
                        if (TextUtils.isEmpty( s.toString() ))
                            return;
                        if (s.toString().equals( list.get( position ).needRemarkParam )) {
                            ((TaskHolder) holder).edt_remark_first.setVisibility( View.VISIBLE );
                        } else {
                            ((TaskHolder) holder).edt_remark_first.setVisibility( View.GONE );
                            ((TaskHolder) holder).edt_remark_first.setText( "" );
                        }
                    }
                } );

                ((TaskHolder) holder).edt_remark_first.addTextChangedListener( new TextWatcher() {
                    @Override
                    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                    }

                    @Override
                    public void onTextChanged(CharSequence s, int start, int before, int count) {

                    }

                    @Override
                    public void afterTextChanged(Editable s) {
                        list.get( position ).odRemark = s.toString();
                    }
                } );


                //左眼

                ((TaskHolder) holder).etOsData.setOnClickListener( v -> {
                    dataCustom.clear();
                    pvCustomOptions = null;
                    if (itemType == 0) {
                        hintKeyBoard( ((TaskHolder) holder).etOsData );
                        dataCustom.addAll( (list.get( position )).paramsArray );
                        initLeftOptionPicker( ((TaskHolder) holder).etOsData, position );
                    } else if (itemType == 1) {
                        //数值选项，改为键盘
                        hintKeyBoard( ((TaskHolder) holder).etOsData );
                        requestFocusKeyBoard( ((TaskHolder) holder).etOsData );
                        ((TaskHolder) holder).etOsData.addTextChangedListener( new WatcherZW( ((TaskHolder) holder).etOsData, position, false ) );
//                        int num = Integer.parseInt( list.get( position ).num );
//                        String minValues = list.get( position ).minValues;
//                        Double intMin = Double.parseDouble( minValues );
//                        dataCustom.add( list.get( position ).minValues );
//                        for (int i = 0; i < num; i++) {
//                            Log.e( "doubleData---", intMin + "" );
//                            if (num != dataCustom.size()) {
//                                dataCustom.add( String.valueOf( UtilString.add( intMin, list.get( position ).intervalValues ) ) );
//                            }
//                            intMin = UtilString.add( intMin, list.get( position ).intervalValues );
//                            if (num == dataCustom.size()) {
//                                initLeftOptionPicker( holder.etOsData, list.get( position ).optionId, list.get( position ).optionName, list.get( position ).isDistinguishLrEye + "" );
//                                break;
//                            }
//                        }

                    } else if (itemType == 2) {
                        //是否选项
                        hintKeyBoard( ((TaskHolder) holder).etOsData );
                        dataCustom.add( "是" );
                        dataCustom.add( "否" );
                        initLeftOptionPicker( ((TaskHolder) holder).etOsData, position );
                    }
                } );
                ((TaskHolder) holder).etOsData.addTextChangedListener( new TextWatcher() {
                    @Override
                    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                    }

                    @Override
                    public void onTextChanged(CharSequence s, int start, int before, int count) {

                    }

                    @Override
                    public void afterTextChanged(Editable s) {
                        if (TextUtils.isEmpty( s.toString() ))
                            return;
                        if (s.toString().equals( list.get( position ).needRemarkParam )) {
                            ((TaskHolder) holder).edt_remark_second.setVisibility( View.VISIBLE );
                        } else {
                            ((TaskHolder) holder).edt_remark_second.setVisibility( View.GONE );
                            ((TaskHolder) holder).edt_remark_second.setText( "" );
                        }
                    }
                } );

                ((TaskHolder) holder).edt_remark_second.addTextChangedListener( new TextWatcher() {
                    @Override
                    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                    }

                    @Override
                    public void onTextChanged(CharSequence s, int start, int before, int count) {

                    }

                    @Override
                    public void afterTextChanged(Editable s) {
                        list.get( position ).osRemark = s.toString();
                    }
                } );
            }
        }


        @Override
        public int getItemCount() {
            return list.size();
        }

        class MultipleHolder extends RecyclerView.ViewHolder {
            @BindView(R.id.edt_remark_first)
            EditText edt_remark_first;
            @BindView(R.id.edt_remark_second)
            EditText edt_remark_second;
            @BindView(R.id.recyclerView_first)
            RecyclerView recyclerView_first;
            @BindView(R.id.recyclerView_second)
            RecyclerView recyclerView_second;
            @BindView(R.id.tv_option_name)
            TextView tvOptionName;

            MultipleHolder(View itemView) {
                super( itemView );
                ButterKnife.bind( this, itemView );
            }

        }


        class TaskHolder extends RecyclerView.ViewHolder {

            @BindView(R.id.tv_option_name)
            TextView tvOptionName;
            @BindView(R.id.et_od_data)
            EditText etOdData;
            @BindView(R.id.et_os_data)
            EditText etOsData;
            @BindView(R.id.ll_second)
            LinearLayout ll_second;
            @BindView(R.id.et_unit_right)
            EditText etUnitRight;
            @BindView(R.id.et_unit_left)
            EditText etUnitLeft;
            @BindView(R.id.tv_right)
            TextView tvRight;
            @BindView(R.id.tv_left)
            TextView tvLeft;
            @BindView(R.id.edt_remark_first)
            EditText edt_remark_first;
            @BindView(R.id.edt_remark_second)
            EditText edt_remark_second;


            TaskHolder(View itemView) {
                super( itemView );
                ButterKnife.bind( this, itemView );
            }
        }


    }

    /**
     * 检查必填项
     *
     * @time 2020/6/1 17:23
     */
    private void changeBottomSave(boolean isLoading) {
//        int currentNumber = 0;
//        if (mapsSelection.size() == 0) {
//            //没有必填项，全是选填
//            Iterator itRight = mapsRightData.entrySet().iterator();
//            while (itRight.hasNext()) {
//                Map.Entry entity = (Map.Entry) itRight.next();
//                if (UtilString.isEmpty((String) entity.getValue())) {
//                    //右眼数据有一项为空
//
//                } else {
//                    isCanSubmit = true;
//                    btnConfirm.setBackground(ContextCompat.getDrawable(activity, R.drawable.item_bg_blue_button));
//                    break;
//                }
//            }
//
//
//        } else {
//            //遍历必填项
//            Iterator isSelection = mapsSelection.entrySet().iterator();
//            while (isSelection.hasNext()) {
//                //有空值，不可提交
//                Map.Entry entityIsSelection = (Map.Entry) isSelection.next();
//                Iterator itRight = mapsRightData.entrySet().iterator();
//                while (itRight.hasNext()) {
//                    Map.Entry entity = (Map.Entry) itRight.next();
//                    if (entityIsSelection.getKey().equals(entity.getKey())) {
//                        Iterator itLeft = mapsLeftData.entrySet().iterator();
//                        while (itLeft.hasNext()) {
//                            Map.Entry entityLeft = (Map.Entry) itLeft.next();
//                            if (entityIsSelection.getKey().equals(entityLeft.getKey())) {
//                                Iterator itName = mapsOptionName.entrySet().iterator();
//                                while (itName.hasNext()) {
//                                    Map.Entry entityName = (Map.Entry) itName.next();
//                                    if (entityIsSelection.getKey().equals(entityName.getKey())) {
//                                        Iterator itIsDistinguishLrEye = mapsIsDistinguishLrEye.entrySet().iterator();
//                                        while (itIsDistinguishLrEye.hasNext()) {
//                                            Map.Entry entityitIsDistinguishLrEye = (Map.Entry) itIsDistinguishLrEye.next();
//                                            if (entityIsSelection.getKey().equals(entityitIsDistinguishLrEye.getKey())) {
//                                                if ((int) entityitIsDistinguishLrEye.getValue() == 1) {
//                                                    //区分左右眼
//                                                    if (UtilString.isEmpty((String) entity.getValue()) || UtilString.isEmpty((String) entityLeft.getValue())) {
//                                                        currentNumber += 1;
//                                                    } else {
//                                                        currentNumber += 1;
//                                                    }
//                                                } else {
//                                                    //不区分左右眼
//                                                    if (UtilString.isEmpty((String) entity.getValue())) {
//                                                        if (!isLoading) {
//                                                            Toast.makeText(activity, "请填写" + entityName.getValue() + "数据或者备注", Toast.LENGTH_LONG).show();
//                                                        }
//
//                                                    } else {
//                                                        currentNumber += 1;
//                                                    }
//                                                }
//
//                                            }
//                                        }
////                                                }
//
//
//                                    }
//                                }
//                            }
//
//                        }
//
//                    }
//
//
//                }
//
//            }
//
//            if (currentNumber == mapsSelection.size()) {
//                //必填项全部填完，可以提交
//                isCanSubmit = true;
//                btnConfirm.setBackground(ContextCompat.getDrawable(activity, R.drawable.item_bg_blue_button));
//
//            } else {
//                isCanSubmit = false;
//                btnConfirm.setBackground(ContextCompat.getDrawable(activity, R.drawable.item_bg_light_blue_button));
//            }


//            while (itOptionId.hasNext()) {
//                Map.Entry entityOptionId = (Map.Entry) itOptionId.next();
//                Iterator itRight = mapsRightData.entrySet().iterator();
//                while (itRight.hasNext()) {
//                    Map.Entry entity = (Map.Entry) itRight.next();
//                    if (entityOptionId.getValue().equals( entity.getKey() )) {
//                        Iterator itLeft = mapsLeftData.entrySet().iterator();
//                        while (itLeft.hasNext()) {
//                            Map.Entry entityLeft = (Map.Entry) itLeft.next();
//                            if (entityOptionId.getValue().equals( entityLeft.getKey() )) {
//                                Iterator itName = mapsOptionName.entrySet().iterator();
//                                while (itName.hasNext()) {
//                                    Map.Entry entityName = (Map.Entry) itName.next();
//                                    if (entityOptionId.getValue().equals( entityName.getKey() )) {
//                                        //遍历必填项
//                                        Iterator isSelection = mapsSelection.entrySet().iterator();
//                                        while (isSelection.hasNext()) {
//                                            //有空值，不可提交
//
//                                            Map.Entry entityIsSelection = (Map.Entry) isSelection.next();
//                                            if (entityOptionId.getValue().equals( entityIsSelection.getKey() )) {
//
////                                                if ((Integer) entityIsSelection.getValue() == 1) {
//                                                Iterator itIsDistinguishLrEye = mapsIsDistinguishLrEye.entrySet().iterator();
//                                                while (itIsDistinguishLrEye.hasNext()) {
//                                                    Map.Entry entityitIsDistinguishLrEye = (Map.Entry) itIsDistinguishLrEye.next();
//                                                    if (entityOptionId.getValue().equals( entityitIsDistinguishLrEye.getKey() )) {
//                                                        if ((int) entityitIsDistinguishLrEye.getValue() == 1) {
//                                                            //区分左右眼
//                                                            if (UtilString.isEmpty( (String) entity.getValue() ) || UtilString.isEmpty( (String) entityLeft.getValue() ) || UtilString.isEmpty( tv_remark.getText().toString() )) {
//                                                                Toast.makeText( activity, "请填写" + entityName.getValue() + "左右眼数据或者备注", Toast.LENGTH_LONG ).show();
//                                                                btnConfirm.setBackground( ContextCompat.getDrawable( activity, R.drawable.item_bg_light_blue_button ) );
//                                                            } else {
//                                                                btnConfirm.setBackground( ContextCompat.getDrawable( activity, R.drawable.item_bg_blue_button ) );
//                                                            }
//                                                        } else {
//                                                            if (UtilString.isEmpty( (String) entity.getValue() ) || UtilString.isEmpty( tv_remark.getText().toString() )) {
//                                                                Toast.makeText( activity, "请填写" + entityName.getValue() + "右眼数据或者备注", Toast.LENGTH_LONG ).show();
//                                                                btnConfirm.setBackground( ContextCompat.getDrawable( activity, R.drawable.item_bg_light_blue_button ) );
//
//                                                            } else {
//                                                                btnConfirm.setBackground( ContextCompat.getDrawable( activity, R.drawable.item_bg_blue_button ) );
//                                                            }
//                                                        }
//
//                                                    }
//                                                }
////                                                }
//
//
//                                            }
//                                        }
//
//                                    }
//                                }
//                            }
//
//                        }
//
//                    }
//
//
//                }
//            }


//        }


//        if (isCanSubmit) {
//            btnConfirm.setBackground( ContextCompat.getDrawable( activity, R.drawable.item_bg_blue_button ) );
//        } else {
//            btnConfirm.setBackground( ContextCompat.getDrawable( activity, R.drawable.item_bg_light_blue_button ) );
//        }
    }

    private void showRemarkDialog() {
        if (mRemarkDialog == null) {
            mRemarkDialog = mRemarkDialog.newInstance( true, false );
            mRemarkDialog.show( getChildFragmentManager(), "mRemarkDialog" );
            mRemarkDialog.setmListener( new RemarkDialog.OnItemClickListener() {
                @Override
                public void onConfirm(String reason, int type) {
                    if (!UtilString.isEmpty( reason )) {
//                        tv_remark.setTextColor(ContextCompat.getColor(activity, R.color.lightBlack));
//                        tv_remark.setText(reason);
                        changeBottomSave( false );
                    } else {
                        //清空
//                        tv_remark.setTextColor(ContextCompat.getColor(activity, R.color.ffd3dcdc));
//                        tv_remark.setText("备注：无检测数据必填，否则视为未筛查");
                        changeBottomSave( false );
                    }

//                    if (type == 1) {
//                        edt_remark.setVisibility(View.GONE);
//                    } else if (type == 2) {
//                        edt_remark.setVisibility(View.VISIBLE);
//                    }
                    mRemarkDialog.dismiss();
                }
            } );
        } else if (!mRemarkDialog.isAdded() && !mRemarkDialog.isShowing()) {
            mRemarkDialog.show( getChildFragmentManager(), "mRemarkDialog" );
        }
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
            savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView( inflater, container, savedInstanceState );
        unbinder = ButterKnife.bind( this, rootView );
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }


    /**
     * 输入监听
     *
     * @time 2020/9/8 10:37
     */
    private class WatcherZW implements TextWatcher {
        EditText etTextView;
        int position;
        Boolean isRight;

        public WatcherZW(EditText etOdData, int position, boolean isRight) {
            this.etTextView = etOdData;
            this.position = position;
            this.isRight = isRight;
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {

            if (isRight) {
                if (!UtilString.isEmpty( etTextView.getText().toString().trim() )) {
                    list.get( position ).odData = etTextView.getText().toString().trim();
                }
                changeBottomSave( false );
            } else {
                if (!UtilString.isEmpty( etTextView.getText().toString().trim() )) {
                    list.get( position ).osData = etTextView.getText().toString().trim();
                }
                changeBottomSave( false );

            }


        }
    }

    @Override
    public void onDestroy() {
        EventBus.getDefault().unregister( this );
        super.onDestroy();
    }

    /**
     * 初始化右眼选择器
     *
     * @time 2020/5/28 11:39
     */
    private void initRightOptionPicker(EditText etOdData, int position) {

        pvCustomOptions = new OptionsPickerBuilder( getActivity(), new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int option2, int options3, View v) {
                //返回的分别是三个级别的选中位置
                //LinkedHashMap 有序
                String tx = dataCustom.get( options1 );
                if (!UtilString.isEmpty( tx )) {
                    etOdData.setText( tx );
                    list.get( position ).odData = tx;
                    changeBottomSave( false );
                }

            }
        } ).build();


        pvCustomOptions.setNPicker( dataCustom, null, null );
        pvCustomOptions.show();
    }

    /**
     * 初始化左眼选择器
     *
     * @time 2020/5/28 11:39
     */
    private void initLeftOptionPicker(EditText etOsData, int position) {

        pvCustomOptions = new OptionsPickerBuilder( getActivity(), new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int option2, int options3, View v) {
                //返回的分别是三个级别的选中位置
                //LinkedHashMap 有序

                String tx = dataCustom.get( options1 );
                if (!UtilString.isEmpty( tx )) {
                    etOsData.setText( tx );
                    list.get( position ).osData = tx;
                    changeBottomSave( false );
                }

            }
        } ).build();


        pvCustomOptions.setNPicker( dataCustom, null, null );
        pvCustomOptions.show();
    }
}
